package com.zr.storehouse.mapper;

import com.zr.storehouse.model.ResAttribute;
import com.zr.storehouse.model.ResDetailsUpdateVo;
import com.zr.storehouse.model.ResDetailsVo;
import com.zr.storehouse.model.StorageDetailsVo;
import org.apache.ibatis.annotations.*;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2019/1/11.
 */
@Mapper
public interface StoreMapper {
    @Select("select id,code,name from resattribute")
    List<ResAttribute> findAttr();

    List<ResDetailsVo> queryRdPage(ResDetailsVo resDetailsVo);

    int getRdCount(ResDetailsVo resDetailsVo);
@Select("select * from storagedetails where id=#{wareHouseId}")
    List<StorageDetailsVo> queryStorePage(@Param("wareHouseId") Integer wareHouseId);
@Select("SELECT * from resdetails where code=#{code} or name=#{name}")
    List<ResDetailsVo> findByCode(@NotBlank(message = "库区编码不能为空")@Param("code") String code, @NotBlank(message = "库区名字不能为空")@Param("name") String name);
@Select("select * from resdetails where id=#{id}")
    List<ResDetailsVo> findById(@Param("id") Integer id);
//@Delete("delete from resAttribute where id in (#{ids})")
    void deleteAttribute(@Param("ids") List<Integer> ids);

    void InsertAttribute(@Param("businessAttribute") List<ResAttribute> businessAttribute);

    int Update(ResDetailsUpdateVo resDetailsUpdateVo);
@Select("select * from storageDetails")
    List<StorageDetailsVo> queryAllStore();

    int InsertResDtails(@Valid ResDetailsUpdateVo resDetailsVo);

    void InsertMiddle(Map map);
@Select("select * from attribute_details ad left join  resattribute r on ad.attr_id=r.id where resD_id =#{id} ")
    List<ResAttribute> findMiddle(Integer id);

    void updateStatus(ResDetailsVo resDetailsVo);

    void updateAttribute(Map map);
@Select("select id from attribute_details where resD_id=#{Id}")
    List<Integer> findMiddleId(@Param("Id") Integer Id);
    @Select("SELECT * from resdetails where  name=#{name}")
    List<ResDetailsVo> findByNmae(@Param("name")@NotBlank(message = "库区名字不能为空") String name);
}
